<template>
  <div>
    fsd{{ count }}
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
// import { createWorker } from 'tesseract.js'
// import Tesseract from 'tesseract.js'
const count = ref(2)
const { createWorker } = (window as any).Tesseract

// const worker = createWorker({
//   workerPath: '../../../public/tesseract/worker.min.js',
//   langPath: '../../../public/tesseract/lang-data',
//   corePath: '../../../public/tesseract/tesseract-core.wasm.js',
//   logger: (m:any) => console.log(m)
// })
// console.log(worker)
// worker.then((res:any) => {
//   console.log(res, 8)
// })

async function init() {
  // await worker.loadLanguage('chi_sim');
  // await worker.initialize('chi_sim');
  // const { data: { text } } = await worker.recognize('../../assets/123.jpg');
  // //这里我使用了我自己的图片目录，
  // //在实际使用时需要改成你自己的图片路径
  // console.log(text);
  // await worker.terminate();
  // console.time()
  const worker = createWorker({
    workerPath: './public/tesseract/worker.min.js',
    langPath: './public/tesseract/lang-data',
    corePath: './public/tesseract/tesseract-core.wasm.js',
  })
  worker.then((res: any) => {
    console.log(res)
  })
  // await worker.loadLanguage('chi_sim');
  // await worker.initialize('chi_sim');
  // await worker.loadLanguage('eng')
  // await worker.initialize('eng')
  // const data = await worker.recognize('../../assets/123.jpg')
  // console.log(data)

  // console.timeEnd()
  // await worker.terminate(); // 终止woker线程，节省内存资源
  // Tesseract.recognize(
  //   '../../assets/123.jpg',
  //   'chi_sim',
  //   {logger: (m:any) => console.log(m, '===>')}
  // ).then(res => {
  //   console.log(res, 99)
  // })
  
}

init()



</script>
